package com.x.reader.dao;

import com.x.framework.Base;
import com.x.framework.dao.BaseDao;
import com.x.reader.model.App;
import com.x.reader.model.Banner;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class BannerDao extends BaseDao {

    private final static String selectBannerListSql = "select t1.* from reader_banner t1 where 1 = 1 ";

    public List<Banner> selectBannerList(Banner banner) throws Exception {
        StringBuilder sb = new StringBuilder(selectBannerListSql);
        List params = new ArrayList();
        if (Base.isNotNull(banner.getBannerId())) {
            sb.append("and t1.banner_id = ? ");
            params.add(banner.getBannerId());
        }
        if (Base.isNotNull(banner.getOrgId())) {
            sb.append("and t1.org_id = ? ");
            params.add(banner.getOrgId());
        }
        sb.append("order by t1.banner_seq");
        return this.queryForList(sb.toString(), Banner.class, params, banner);
    }

}
